<?php

declare(strict_types=1);

namespace app\middleware;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        $header = $request->header();
        // dump($header['referer']);
        if (!isset($header['referer'])) {
            return json(['code' => 451, 'msg' => 'invalid request null']);
        }
        if ($header['referer'] !== 'http://192.168.0.228:8080/') {
            return json(['code' => 451, 'msg' => 'invalid request']);
        }
        return $next($request);
    }
}
